var app = getApp();

Page({
    data: {
        navH: 0,
        plusH: 42,
        plusH2: 67,
        itemChioce: 1,
        sta: 15,
        sliderOffset: -2,
        sliderLeft: 6.5,
        pmH: 0,
        list: !1,
        page: 1,
        lastPage: !1,
        loading: !1,
        source: 1,
        jd_open: 0,
        mg_open: 0,
        vip_open: 0,
        sn_open: 0,
        source_open: !0,
        source_top: 0,
        balance: "",
        goods_id: "",
        order_id: "",
        source_d: "",
        price: "",
        checked: !1,
        tb_order_sn: ""
    },
    toGoodsPage: function(a) {
        console.log(a);
        var t, e = a.currentTarget.dataset.goods_id;
        0 != e && (t = a.currentTarget.dataset.source, void 0 !== a.currentTarget.dataset.source ? (t = "&source=" + t, 
        wx.navigateTo({
            url: "../goods/goods?goods_id=" + e + t
        })) : wx.navigateTo({
            url: "../goods/goods?goods_id=" + e
        }));
    },
    setTbOrdersn: function(a) {
        this.setData({
            tb_order_sn: a.detail.value
        });
    },
    emptyTbOrdersn: function() {
        this.setData({
            tb_order_sn: ""
        });
    },
    lookupTbOrder: function() {
        var t = this;
        t.data.tb_order_sn ? t.data.loading || (t.data.loading = !0, app.util.request({
            url: "entry/wxapp/lookTbOrder",
            data: {
                order_sn: t.data.tb_order_sn
            },
            success: function(a) {
                t.data.loading = !1, t.emptyTbOrdersn(), console.log(a.data.data), wx.showToast({
                    title: "订单已找回",
                    icon: "success"
                }), setTimeout(function() {
                    t.data.page = 1, t.data.lastPage = !1, t.getOrderList();
                }, 1500);
            }
        })) : wx.showToast({
            title: "订单号不能为空",
            icon: "none"
        });
    },
    switchSource: function(a) {
        var t = this;
        console.log(a);
        var e = a.target.dataset.source, o = a.target.dataset.idx, a = 0, a = 4 < o ? 30 * o : 0 * o;
        e != t.data.source && (t.setData({
            source: e,
            itemChioce: 1,
            sliderOffset: -2,
            sliderLeft: 6.5,
            order_sn: "",
            checked: !1,
            scrollLeft: a
        }), t.data.page = 1, t.data.lastPage = !1, t.getOrderList());
    },
    showTip: function(a) {
        a = a.currentTarget.dataset.idx, app.showInfo(this, "该笔订单失效原因：" + this.data.list[a].order_status_desc);
    },
    hideInfo: function() {
        app.hideInfo(this);
    },
    copySn: function(a) {
        a = a.currentTarget.dataset.idx, wx.setClipboardData ? wx.setClipboardData({
            data: this.data.list[a].order_sn,
            success: function(a) {
                app.globalData.showSmart = !1, wx.showToast({
                    title: "复制成功"
                });
            }
        }) : console.log("当前微信版本不支持setClipboardData");
    },
    goChangeTeam: function(a) {
        var t = a.currentTarget.dataset.replyType, e = a.currentTarget.dataset.status;
        t == (a = this).data.itemChioce || (a.setData({
            itemChioce: t,
            sta: e
        }), console.log(e), 1 == a.data.itemChioce && a.setData({
            sliderOffset: -2,
            sliderLeft: 6.5
        }), 2 == a.data.itemChioce && a.setData({
            sliderOffset: 17,
            sliderLeft: 6.5
        }), 3 == a.data.itemChioce && a.setData({
            sliderOffset: 36,
            sliderLeft: 6.5
        }), 4 == a.data.itemChioce && a.setData({
            sliderOffset: 55,
            sliderLeft: 6.5
        }), 5 == a.data.itemChioce && a.setData({
            sliderOffset: 74,
            sliderLeft: 6.5
        }), a.data.page = 1, a.data.lastPage = !1, a.getOrderList());
    },
    getOrderList: function(t) {
        var e = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "cover", o = this, a = 1 != o.data.balance ? 1 == o.data.itemChioce ? {
            page: o.data.page,
            source: o.data.source
        } : {
            page: o.data.page,
            status: o.data.sta,
            source: o.data.source
        } : {
            page: o.data.page,
            status: 3,
            source: o.data.source
        };
        1 == o.data.page && wx.pageScrollTo({
            scrollTop: 0,
            duration: 0
        }), o.data.loading || (o.data.loading = !0, app.util.request({
            url: "entry/wxapp/getOrderList",
            data: a,
            success: function(a) {
                if (o.data.loading = !1, "function" == typeof t && t(), "append" == e) {
                    if (!a.data.data.length) return !(o.data.lastPage = !0);
                    o.data.list = o.data.list.concat(a.data.data);
                } else o.data.list = a.data.data;
                o.setData({
                    list: o.data.list
                });
            }
        }));
    },
    onLoad: function(a) {
        console.log("进入", a);
        var t = this;
        void 0 !== a.balance && 1 == a.balance && t.setData({
            itemChioce: 4,
            balance: a.balance,
            plusH2: 0
        }), t.setData({
            navH: app.globalData.navHeight,
            tb_open: app.globalData.setting.tb_open,
            jd_open: app.globalData.setting.jd_open,
            mg_open: app.globalData.setting.mg_open,
            vip_open: app.globalData.setting.vip_open,
            sn_open: app.globalData.setting.sn_open,
            kl_open: app.globalData.setting.kl_open,
            mt_open: app.globalData.setting.mt_open
        }), t.data.jd_open || t.data.mg_open || t.data.vip_open || t.data.sn_open || t.setData({
            source_open: !1,
            plusH: 0
        }), void 0 !== a.tb_order_sn ? t.setData({
            source: a.source,
            tb_order_sn: a.tb_order_sn
        }, function() {
            t.getOrderList(function() {
                t.lookupTbOrder();
            });
        }) : t.getOrderList(), app.checkUserSub("4|5");
    },
    navBack: function() {
        wx.navigateBack();
    },
    toIndex: function() {
        wx.switchTab({
            url: "../index/index"
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.page = 1, this.data.lastPage = !1, this.getOrderList(function() {
            wx.stopPullDownRefresh();
        });
    },
    onReachBottom: function() {
        var a = this;
        if (!0 === a.data.lastPage) return !1;
        wx.showLoading({
            title: "加载中"
        }), a.data.page++, a.getOrderList(function() {
            wx.hideLoading();
        }, "append");
    },
    radioChange: function(a) {
        console.log("eee", a), console.log("radio发生change事件，携带value值为：", a.detail.value);
        var t = (o = a.detail.value).split(",");
        console.log(o), console.log(t);
        var e = t[0], a = t[1], o = t[2], t = t[3];
        this.setData({
            goods_id: e,
            order_id: a,
            source_d: o,
            price: t
        });
    },
    backDryPage: function(a) {
        console.log(a);
        var t = [ a.target.dataset.goods_id, a.target.dataset.order_id, a.target.dataset.source_d, a.target.dataset.price ];
        (a = getCurrentPages())[a.length - 2].setData({
            returnedValue: t
        }), wx.navigateBack({
            delta: 1
        });
    }
});